define(["app", "angular", "services/BaseService"], function(app, angular) {
	
	var deps = ["$http", "BaseService"];
	
	function doubleDetailResource($http, BaseService) {
        return initResource($http, BaseService.restfulUrl + "doubleAuthority/", BaseService.formHeader);
    }
	
	var postHeader = {
	        "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8"
	};
	
	function initResource($http, preUrl,formHeader) {
        return {
        	
        	/**
        	 * 获取有双人通话的用户列表
        	 * orgId 当前组织ID
        	 * pageNo 当前页
        	 * pageSize 每页大小
        	 * companyCode 注册单位
        	 */
            queryDoubleAuthorityUserList: function (orgId,pageNo,pageSize,companyCode,searchKey) {
                return $http.get(preUrl + "queryDoubleAuthorityUserList", {
                    params: {
                    	orgId: orgId,
                        pageSize: pageSize || 10000,
                        pageNo: pageNo || 1,
                        companyCode: companyCode,
                        searchKey:searchKey
                    }
                });
            },
            
    		/**
             * 删除用户权限-批量删除
             * userId 用户ID
             * companyCode 用户注册单位
             * doubleAuthority 删除的权限
             */
    		deleteUsersAuthority : function(userIds, companyCode,doubleAuthority) {
    			return $http.post(preUrl + "deleteUserAuthority", {
    				userIds :userIds,
    				companyCode : companyCode,
    				doubleAuthority:doubleAuthority
    			}, {
    				headers : postHeader
    			});
    		},
    		
            
            /**
    		 * 设置任务权限 新增、删除
    		 * 
    		 * @param orgIds 组织ID
    		 * @param type 0 新增 1删除
    		 * @param time 双人通话时长
    		 * 
    		 * @returns {*|Object}
    		 */
            grantDoubleAuthority : function(userIds, type,companyCode,time,chooseType) {
    			return $http.post(preUrl + "grantDoubleAuthority", {
    				userIds : angular.isArray(userIds) ? userIds : [userIds],
    				type : type,
    				chooseTime:time,
    				companyCode:companyCode,
    				chooseType:chooseType
    			}, {
    				headers : postHeader
    			});
    		}
        };
        
    }
	doubleDetailResource.$inject = deps;
	app.lazy.factory("DoubleDetailResource", doubleDetailResource);
});
